Fselect(2) Oct. 1, 1991 Fselect(2) NAME Fselect - select file descriptors that are ready for reading or writing SYNOPSIS WORD Fselect(WORD timeout, LONG *rfds, LONG *wfds, ((long)0)); DESCRIPTION Fselect checks two sets of open file descriptors and deter- mines which have data ready to read, and/or which are ready to be written to. If none are ready yet, the process goes to sleep until some member of the sets are ready or until a specified amount of time has elapsed. rfds points to a long word which represents a set of GEMDOS file descriptors; bit n of this long word is set if file descriptor n is to be checked for input data. An empty set may optionally be represented by a NULL pointer instead of a pointer to 0. Similarly, wfds points to a 32 bit long word which indicates which file descriptors are to be checked for output status. When Fselect returns, the old values pointed to by rfds and wfds (if non-NULL) are overwritten by new long words indicating which file descriptors are actually ready for reading or writing; these will always form subsets of the file descriptors originally specified as being of interest. timeout is a 16 bit unsigned integer specifying a maximum number of milliseconds to wait before returning; if this number is 0, no maximum is set and the call will block until one of the file descriptors specified is ready for reading or writing, as appropriate. Thus, Fselect(0,0L,0L,0L) will block forever, whereas Fselect(1,0L,0L,0L) will pause for 1 millisecond. The final argument, a long word, must always be 0 (it is reserved for future enhancements). RETURNS The sum of the numbers of bits set in the long words pointed to by rfds and wfds. This will be 0 if the timeout expires without any of the specified file descriptors becoming ready for reading or writing, as appropriate, and nonzero other- wise. EIHNDL if any handle specified by the long words pointed to by rfds or wfds is not a valid (open) GEMDOS handle. SEE ALSO Finstat(2), Foutstat(2) Version 0.9 Last change: MiNT Programmer's Manual 1 Fselect(2) Oct. 1, 1991 Fselect(2) BUGS The system timer is not actually accurate to the nearest millisecond, so the timeout could last for up to 19 mil- liseconds longer than specified. Fselect does not work correctly on any BIOS device except the keyboard. Note that if an error condition occurs on one of the file descriptors (for example, if the read status of a pipe with no more writers is being requested) then Fselect will mark that file descriptor as being ready for reading (or writing, as appropriate). This is not strictly speaking a bug, since a subsequent read will not block (it will return an error condition), but programmers should be aware of the possibil- ity. Version 0.9 Last change: MiNT Programmer's Manual 2